package com.cosmoplat.xikai.business.controller.scada;


import com.cosmoplat.xikai.business.domain.dto.scada.DeviceFaultDto;
import com.cosmoplat.xikai.business.service.DeviceFaultService;
import com.cosmoplat.xikai.common.core.controller.BaseController;
import com.cosmoplat.xikai.common.core.domain.AjaxResult;
import com.cosmoplat.xikai.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/device/fault")
@Api(tags = "设备故障管理", value = "设备故障管理")
public class DeviceFaultController extends BaseController {
    @Autowired
    private DeviceFaultService deviceFaultService;

    /**
     * 设置请求分页数据
     */

    @ApiOperation(value = "分页查询")
    @PreAuthorize("@ss.hasPermi('scada:deviceFault:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceFaultDto deviceFaultDto) {
        startPage();
        return getDataTable(deviceFaultService.queryForPage(deviceFaultDto));
    }


    /**
     * 告警统计
     *
     * @param deviceFaultDto
     * @return
     */
    @ApiOperation(value = "告警数据统计")
    @PostMapping("/alarm/data/statistics")
    public AjaxResult alarmDataStatistics(@RequestBody(required = false) DeviceFaultDto deviceFaultDto) {
        return AjaxResult.success(deviceFaultService.alarmDataStatistics(deviceFaultDto));
    }


}
